package cn.omisheep.autt.core;

import cn.omisheep.commons.util.web.ConvertUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.List;

public class Cookies extends HashMap<String, String> {

    public Cookies() {
        super();
    }

    public void putList(List<Cookies> cookieList) {
        for (Cookies cookies : cookieList) {
            putAll(cookies);
        }
    }

    @Override
    public String toString() {
        try {
            return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String toPropertyString() {
        return ConvertUtil.mapToString(this);
    }
}
